package jm.java.bytecode;

/**
 * @Description 懒惰初始化单例模式实现
 * @date 2022/3/29 9:45
 */
public class SingleObject {
    public static void main(String[] args) {
        Singleton.getInstance();
    }
}

class Singleton{
    private Singleton() {}

    private static class LazyHolder{
        private static final Singleton SINGLETON = new Singleton();
        static {
            System.out.println("初始化 LazyHolder");
        }
    }

    public static Singleton getInstance(){
        return LazyHolder.SINGLETON;
    }
}
